home *** CD-ROM | disk | FTP | other *** search
/ World of Video / World of Video.iso / gfxprograms / 3dprograms / t3dlib / source / tddd2dxf.c < prev    next >
C/C++ Source or Header  |  1995-02-13  |  1KB  |  60 lines

  1. /* tddd2dxf.c - convert TDDD (or TTDDD) file to DXF file
  2.  *            - written by Glenn M. Lewis - 10/29/91
  3.  */
  4.  
  5. static char rcs_id[] = "$Id: tddd2dxf.c,v 1.3 1993/01/31 17:22:21 glewis Exp $";
  6.  
  7. #include <stdio.h>
  8. #include "t3dlib.h"
  9. #ifdef __STDC__
  10. #include <stdlib.h>
  11. #include <strings.h>
  12. #include "tddd2dxf_protos.h"
  13. #endif
  14.  
  15. main(argc, argv)
  16. int argc;
  17. char *argv[];
  18. {
  19.     char filename[256], rootname[256], *c1, *c2;
  20.     int i;
  21.     WORLD *world;
  22.     FILE *inp, *out;
  23.  
  24.     filename[0] = '\0';
  25.     rootname[0] = '\0';
  26.     for (i=1; i<argc; i++) {
  27.         if (argv[i][0] == '-') {
  28.             if (argv[i][1] == 'h') {
  29.                 fprintf(stderr, "Usage: %s [infile] [outfile]\n", argv[0]);
  30.                 exit(-1);
  31.             }
  32.             fprintf(stderr, "Unknown option '%s' ignored.\n", argv[i]);
  33.         } else if (filename[0]) {
  34.             strcpy(rootname, argv[i]);
  35.         } else {
  36.             strcpy(filename, argv[i]);    /* Make root of filename the default */
  37.             for (c1=rootname,c2=argv[i]; (*c1 = *c2++) && *c1!='.'; c1++) ;
  38.             *c1 = '\0';
  39.             strcat(rootname, ".dxf");
  40.         }
  41.     }
  42.  
  43.     if (!filename[0]) inp = stdin;
  44.     else if (!(inp = fopen(filename, "r"))) {
  45.         fprintf(stderr, "Can't open '%s' for input.\n", filename);
  46.         exit(-1);
  47.     }
  48.     if (!rootname[0]) out = stdout;
  49.     else if (!(out = fopen(rootname, "w"))) {
  50.         fprintf(stderr, "Can't open '%s' for output.\n", rootname);
  51.         exit(-1);
  52.     }
  53.  
  54.     world = read_World(inp);
  55.     write_DXF(world, out);
  56.     free_World(world);
  57.     exit(0);
  58. }
  59.  
  60.